varying vec3 LightDir;
varying vec3 EyeDir;

uniform vec3 LightPosition;

attribute vec3 Tangent;

void main()
{

   EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
   gl_TexCoord[0] = gl_MultiTexCoord0;

   vec3 N = normalize(gl_NormalMatrix * gl_Normal);
   vec3 T = normalize(gl_NormalMatrix * Tangent);
   vec3 B = cross(N, T);

   mat3 TBNt = transpose(mat3(T, B, N));

   LightDir = normalize(TBNt * LightPosition);
   EyeDir = normalize(TBNt * EyeDir);

   distance = sqrt(dir.x * dir.x + dir.y * dir.y);
   displacement = sqrt(0.25 - distance * distance);

}
